/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-04 10:08:10
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-04 11:00:48
 * @Description: file content
 */

#include "../common/apue.h"
#include <dirent.h>

int main(int argc, char *argv[])
{
    DIR *dp;
    struct  dirent *dirp;

    if (2 != argc)
    {
        err_quit("usage: ls directory_name");
    }

    dp = opendir(argv[1]);
    if (NULL == dp)
    {
        err_sys("can't open %s", argv[1]);
    }

    while (1)
    {
        dirp = readdir(dp);
        if (NULL == dirp)
        {
            break;
        }

        printf("%s\n", dirp->d_name);
    }

    closedir(dp);
    exit(0);
    //return 0;
}
